<script lang="ts" setup>
import {ref, watch, useAttrs} from 'vue'
// import { clickView } from '@/api/workbenches'
import { aesDecrypt } from 'dsrz/utils';

defineOptions({
    name: 'VisitorText',
})
interface Backups {
    nickname?: string;
    phone?: string;
    username?: string;
}
const props = defineProps({
    modelValue: {
        type: String,
        default: '',
    },
    label: {
        type: String,
        default: '',
    },
    isDecrypt: {
        type: Boolean,
        default: false,
    }
})

watch(() => props.modelValue, () => {
    status.value = true
})

const attrs = useAttrs()
const status = ref(true)
const showContent = async() => {
    const { backups } = attrs as { backups?: Backups }
    const name = aesDecrypt(backups?.nickname) ? aesDecrypt(backups?.nickname) : backups?.nickname
    status.value = !status.value
    console.log('props.modelValue------->',props.modelValue, '==  ', `查看了${name}的${props.label}-`)

    // await clickView({
    //     content: `查看了${name}的${props.label}--`
    // })
}
</script>
<template>
    <CurrencyButton
        v-if="status"
        :title="'点击查看'"
        link
        @click="showContent"
    />
    <span v-else>
    {{ isDecrypt ? aesDecrypt(modelValue) : modelValue }}
  </span>
</template>
<style lang="scss" scoped></style>